<!--
 * @Author: wanglidong
 * @Date: 2021-04-08 09:23:01
 * @LastEditTime: 2022-07-04 17:21:21
 * @LastEditors: wanglidong
 * @Description:
 * @FilePath: \lowcode-front\src\views\investment\monthInvestProgress\monthInvestProgress-detail.vue
 * @nbsg
-->
<template>
  <div class="pre-archive-detail">
    <el-dialog width="70%" class="WholeScroll" :visible.sync="formShow" @close="handleClickDeal('cancel')" v-dialog-drag :modal-append-to-body="false" :close-on-click-modal="false">
      <span slot="title">
        <i class="iconfont icon-a-qushitiaoxingtu-08"></i>
        <span>{{ title }}</span>
      </span>

      <el-tabs v-model="activeName" style="width:100%;">
        <el-tab-pane label="基本信息" name="first">
          <div class="WholeScroll" style="max-height: 650px; overflow: auto;padding-right:10px;margin-top: 10px;">
            <el-form :model="formBaseData" ref="formBaseData" :rules="formBaseRules" style="position: relative">
              <el-row>
                <el-col :span="12">
                  <el-form-item label="公司" prop="companyId" :label-width="formlabelWidth">
                    <el-select class="select" v-on:change="getProjectByCompanyId()" value-key="id" v-model="formBaseData.companyId" placeholder="选择公司" style="width: 100%" clearable :disabled="detailType != 'build' || isLock">
                      <el-option v-for="item in companyTree" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目" prop="projectId" :label-width="formlabelWidth">
                    <el-select class="select" v-on:change="getProjectChange()" style="width: 100%" value-key="id" v-model="formBaseData.projectId" placeholder="选择项目" clearable :disabled="detailType != 'build' || isLock">
                      <el-option v-for="item in projectTree" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="12">
                  <el-form-item label="填报月份选择" prop="yearMonthStr" :label-width="formlabelWidth">
                    <el-date-picker v-model="formBaseData.yearMonthStr" :disabled="detailType != 'build' || isLock" style="width: 100%;" type="month" :clearable="false" :picker-options="pickerOptions" value-format="yyyy-MM" @change="chooseDatePicker" placeholder="选择日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="12">
                  <el-form-item label="" :label-width="formlabelWidth">
                    <el-button style="width: 100%;" :disabled="isLock||detailType!='build'" type="primary" @click="lockForm"> 开始填报
                    </el-button>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="22">
                  <el-form-item label="附件" :label-width="formlabelWidth">
                    <cmsUploadFile ref="fileOne" :fileList="fileListArr" :detail-id="detailId" :fileSystem="fileSystem['one']" :disabled="detailType === 'check'|| detailType === 'approve'" type="mul" info="支持上传 png/jpg/gif/doc/xlsx/ppt/pdf 文件" :detail-type="detailType" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="isLock">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="月实际完成产值" prop="monthActualFinishValue" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.monthActualFinishValue" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check' || isBfg === '1'">
                        <template slot="append">万元</template>
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="累计完成进度" prop="accumulatedFinish" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.accumulatedFinish" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check' || isBfg === '1'">
                      </el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row v-if="isBfg === '1'">
                  <el-col :span="12">
                    <el-form-item label="月实际完成产值（报发改）" prop="monthActualFinishValueBfg" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.monthActualFinishValueBfg" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check'">
                        <template slot="append">万元</template>
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="累计完成进度（报发改）" prop="accumulatedFinishBfg" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.accumulatedFinishBfg" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check'">
                      </el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :span="12">
                    <el-form-item label="月实际支付" prop="monthActualPay" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.monthActualPay" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check' || isBfg === '1'">
                        <template slot="append">万元</template>
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="累计支付比例" prop="accumulatedPayRate" :label-width="formlabelWidth">
                      <el-input v-model="formBaseData.accumulatedPayRate" @keyup.native="newUpNumber" @keydown.native="newUpNumber" :disabled="detailType === 'check' || isBfg === '1'">
                      </el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :span="24">
                    <el-form-item label="月完成情况说明" prop="finishDescription" :label-width="formlabelWidth">
                      <el-input type="textarea" :rows="10" placeholder="请输入月完成情况说明" v-model="formBaseData.finishDescription" :disabled="detailType === 'check' || isBfg === '1'"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="目前进度说明" prop="currentDescription" :label-width="formlabelWidth">
                      <el-input type="textarea" :rows="10" placeholder="请输入目前进度说明" v-model="formBaseData.currentDescription" :disabled="detailType === 'check' || isBfg === '1'"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-row>
            </el-form>
          </div>
        </el-tab-pane>
      </el-tabs>

      <div slot="footer" class="dialog-footer">
        <template v-if="detailType === 'build' || detailType === 'edit'">
          <el-button size="small" type="primary" :loading="isLoading" @click="handleClickDeal('submit', { flag: 1 })"><i class="iconfont icon-icon_save"></i> 确 定
          </el-button>
        </template>
        <el-button size="small" @click="handleClickDeal('cancel')"><i class="iconfont icon-icon_cancel"></i> 取 消
        </el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { v4 as uuidv4 } from 'uuid';

import msgUtil from '@/utils/msgUtil'
import projectSectionInfo from '@/api/buss/common'
import WfProcess from '@/components/WorkFlow/process/index'
import PopBtn from '@/components/ExtBpmn/Btn/index'
import BpmnForm from '@/components/ExtBpmn/ExtForm/bpmn-form'
import startMixin from "@/mixins/wfStartMixin";
import approveMixin from "@/mixins/wfApproveMixin";

import { timeFormat } from '@/utils/time.js'
const PREVIEW_URL = process.env.VUE_APP_FILE_PREVIEW


export default {
  name: 'monthInvestProgress-detail',
  components: {
    WfProcess,
    BpmnForm,
    PopBtn
  },
  mixins: [startMixin, approveMixin],
  props: {
    postDetail: {
      type: Object,
      default: {
        show: false,
        type: 'build',
        params: {}
      },
    },

  },
  watch: {
    'rightContent': {
      handler(val) {
      },
      deep: true
    },
    postDetail(value) {
      console.log(value)
      // 显示详情弹窗
      this.formShow = value.show
      // 初始化窗口参数
      // 详情类型
      this.detailType = value.type

      if (this.detailType == 'build') {
        this.title = '新增月投资进度'
        this.showBpmnForm = true
        this.isShowBpmn = true
        let now = new Date()
        now.setMonth(this.$parent.leftListIndex)
        this.formBaseData.yearMonthStr = timeFormat(now, 'yyyy-MM')
      } else if (this.detailType == 'check') {
        this.title = '查看月投资进度'
      } else if (this.detailType == 'edit') {
        this.title = '编辑月投资进度'
        this.showBpmnForm = true
        this.isShowBpmn = true
      }
      else if (this.detailType == 'approve') {
        this.title = '月投资进度'
        this.showBpmnForm = true
        this.isShowBpmn = true
      } else {
        this.title = ''
      }
      this.activeName = 'first'
      this.showAudit = true
      // 详情id
      // this.detailId = value.detailId?value.detailId:'';
      this.detailId = value.detailId ? value.detailId : value.params ? value.params.detailId : '' ? value.params.detailId : ''

      let userRoles = JSON.parse(localStorage.getItem('roles'))
      console.log(userRoles)
      userRoles.forEach(role => {
        if (role.id === 'ff8080818bb7e690018bccc0073e0056') {
          this.isBfg = '1';
        }
      })
      if (this.detailType != 'build') {
        // 获取详情请求
        this.getDetail();
      } else {
        this.getProjectSectionInfoTree();
      }
    }
  },
  data() {
    return {
      wfNode: {},
      showAudit: false,
      readonly: false,
      isShowBpmn: false,
      isMultiple: false,
      activeName: 'first', //
      isLock: false,
      defaultTreeKey: [],
      leftTree: [],
      leftTreeSecond: [],


      defaultProps: {
        children: 'children',
        label: 'name'
      },

      chooseRightObj: {},
      chooseLeftIndex: '',
      rightContent: {
        data: {},
        id: ''
      },

      year: '',
      isBfg: '',
      dateArray: [],
      choseData: '', // 初始化选择日期
      chooseYear: new Date().getFullYear(),
      showChooseDateDialog: false,
      leftArrValue: 0,
      dialogVisible: false,
      videoUrl: '',
      showConsultUnit: true,
      companyTree: [], // 公司下拉
      projectTree: [], // 项目下拉
      verifyList: [], //审批人下拉
      showBpmnForm: false,

      qjbywctz: 0, // 定义一个全局的本月完成投资

      isLoading: false,
      detailType: 'build', // 详情类型 build新建 check不可编辑查看 edit编辑
      taskKey: '', // 详情类型 build新建 check不可编辑查看 edit编辑
      detailId: '', // 当前详情的id
      formShow: false, // 表单展示
      formlabelWidth: '180px', // 表单左侧标题宽度
      formlabelWidthTwo: '220px', // 表单左侧标题宽度
      formlabelWidthThree: '150px', // 表单左侧标题宽度
      formlabelWidthFore: '100px', // 表单左侧标题宽度
      formlabelWidthFive: '180px', // 表单左侧标题宽度
      title: '',
      pickerOptions: this.beginDate(),
      pickerOptions0: this.processDate(),
      /* pickerOptions: {
         disabledDate: (time) => {
           if(this.dateArray.includes(this.getLocalTime(time.getTime()))){
             return true
           }
           if(time.getTime() > Date.now() - 8.64e6){
             return true
           }
         }
       },*/
      /*    pickerOptions0: {
            cellClassName: (time)=>{
              if(this.dateArray.includes(this.getLocalTime(time.getTime()))){
                return 'dateRed'
              }
            }
          },*/
      chooseIndex: 0,
      leftArr: [
        {
          name: `当年`
        },
        {
          name: '历年'
        }
      ],
      fileList: [
        {
          name: '月投资进度',
          src: '',
        }
      ],
      fileListArr: [],
      fileSystem: {
        'one': {
          sys: 'buss',
          module: 'monthInvestProgress',
          part: 'one',
          compoName: 'fileOne'
        }
      },

      selectList: {
        isConsultUnit: [{
          name: '是',
          value: 1
        }, {
          name: '否',
          value: 0
        }],
        //所有合同
        projectArr: [],
        companyList: [],
        file: []
      }, // 所有下拉框列表的集合
      afterAmount: '',
      addAmount: '',
      flag: false,

      formBaseData: {
        id: '',
        companyId: '',
        projectId: '',
        verifyId: '',
        yearMonthStr: '',
        // 本月完成
        realChildren: [],
        // 下月计划
        planChildren: [],
        file: [],
        procInstId: '',
        monthActualFinishValue: '',//月实际完成产值
        accumulatedFinish: '',//累计完成进度
        monthActualFinishValueBfg: '',//月实际完成产值（报发改）
        accumulatedFinishBfg: '',//累计完成进度（报发改）
        monthActualPay: '',//月实际支付
        accumulatedPayRate: '',//累计支付比例
        finishDescription: '',//月完成情况说明
        currentDescription: ''//目前进度说明
      }, // 表单基本信息内容
      variables: { needReview: '0' },
      //  允许选择部门
      enableDept: false,
      formBaseRules: {
        companyId: [
          {
            required: true,
            message: '请选择公司',
            trigger: 'blur'
          }
        ],
        projectId: [
          {
            required: true,
            message: '请选择项目',
            trigger: 'blur'
          }
        ],

        yearMonthStr: [
          {
            required: true,
            message: '请选择月份',
            trigger: 'blur'
          }
        ],
        planinvestmentYear: [
          {
            required: true,
            message: '请输入当年计划投资额',
            trigger: 'blur'
          }
        ],

        investmentcompletMonth: [
          {
            required: true,
            message: '请输入本月完成投资额',
            trigger: 'blur'
          }
        ],

        planinvestmentNextMonth: [
          {
            required: true,
            message: '请输入下月计划投资额度',
            trigger: 'blur'
          }
        ],


      } // 表单基本信息验证
    }
  },

  created() {
  },
  methods: {
    beginDate() {
      const self = this
      return {
        disabledDate(time) {
          return time.getTime() > Date.now()//开始时间不选时，结束时间最大值小于等于当天
        }
      }
    },
    processDate() {
      const self = this
      return {
        disabledDate(time) {
          if (self.formBaseData.yearMonthStr) { //如果开始时间不为空，则结束时间大于开始时间
            if (new Date(self.formBaseData.month + ' 00:00:00').getMonth() >= time.getMonth()) {
              return true
            }
            // if(time.getTime() > Date.now()) {
            //   return true
            // }
          } else {
            return time.getTime() > Date.now()//开始时间不选时，结束时间最大值小于等于当天
          }
        }
      }
    },

    showRowTable() {
      if (this.detailType == 'check' || this.detailType == 'approve') {
        return true
      } else {
        return false
      }
    },
    changeTotal(val) {
      if (this.rightContent.name == '建安费') {
        this.$set(this.leftTree[0].children[1], 'score', Number(val))
      }
      if (this.rightContent.name == '其他费用') {
        this.$set(this.leftTree[0].children[0], 'score', Number(val))
      }
    },
    changeInput(item, value) {
      let csh = 0;
      if (value) {
        csh = Number(value);
      }
      let arr = this.leftTree[0].children;
      for (let i = 0; i < arr.length; i++) {
        let baseData = arr[i];
        let name = baseData.name;
        if ('建安费' == name) {
          arr[i].hxjafData1 = csh;
        }
        if ('土地征拆费' == name) {
          arr[i].hxtdzcfData1 = csh;
        }
        if ('工程建设其他费' == name) {
          arr[i].hxgcjsqtfData1 = csh;
        }
        if ('建设期贷款利息' == name) {
          arr[i].hxjsqdklxData1 = csh;
        }
      }
    },

    /*    changeInput2(item,value){
          console.log(item,123123123123)
          console.log(value,'输入的值')
          let csh = 0;
          if(value){
            csh = Number(value);
          }
          item.hxjafData1 = csh
          item.hxtdzcfData1 = csh
          item.hxgcjsqtfData1 = csh
          item.hxjsqdklxData1 = csh
        },*/

    setDataFirst() {
      this.chooseLeftIndex = 0
      this.chooseRightObj = this.rightContent.array[0]
      if (!this.chooseRightObj) {
        this.chooseRightObj = {}
      }

    },
    deleteDataList(index, arrData) {
      this.$confirm('确定是否删除？', '提示', {
        confirmButtonClass: 'iconfont icon-icon_ok',
        cancelButtonClass: 'iconfont icon-icon_cancel',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'info'
      })
        .then(() => {
          if (arrData.length == 1) {
            arrData.splice(index, 1)
            this.chooseLeftIndex = ''
            this.$set(this, 'chooseRightObj', {})
          } else {
            arrData.splice(index, 1)
            // let arr = JSON.parse(JSON.stringify(arrData))
            // this.$set(arrData,'array',arr)
            this.chooseLeftIndex = 0
            this.$set(this, 'chooseRightObj', arrData[0])

            if (!this.chooseRightObj) {
              this.chooseRightObj = {}
            }
          }

        })
        .catch(() => {
        })
    },
    addMeasureBatch(arrList, type) {
      let list = JSON.parse(JSON.stringify(arrList))
      let arr = {
        name: '',
        planWork: '',
        completionCriteria: '',
        nextCompleteMoney: 0,
        needCooperate: '',
      }
      arrList.push(arr)
      if (list.length == 0) {
        this.chooseRightObj = arrList[0]
      }
    },
    spanFunction(name) {
      if (name == '土地征拆费' || name == '建设期贷款利息') {
        return '（建安费/土地征拆费/工程建设其他费/建设期贷款利息）'
      }
      if (name == '基本建设程序' || name == '资金回收' || name == '日常管理') {
        return '（最高10分）'
      }
      if (name == '安全管理' || name == '环保管理' || name == '质量管理' || name == '合同管理') {
        return '（最高5分）'
      }
    },
    handleNodeClick(item, index) {
      this.chooseRightObj = {}
      this.$set(this, 'rightContent', item)
      if (item.name == '建安费' || item.name == '其他费用') {
        this.setDataFirst()
      } else {
        // this.rightContent = this.rightContent.data
      }
    },
    // 公司下拉
    getProjectSectionInfoTree() {
      return projectSectionInfo.getProjectSectionInfoTree().then(res => {
        if (res.code === 200) {
          var data = res.data;
          this.companyTree = data;
          if (this.companyTree.length > 0) {
            if (this.detailType == 'build') {
              this.formBaseData.companyId = this.companyTree[0].id;
            }
          }
          this.getProjectByCompanyId();
          /*return new Promise(reslove=>{
            reslove(res)
          })*/
        } else {
          msgUtil.error2(res.data.message)
        }
      })
    },

    /**
     * 项目变更时 获取已经存在的日期
     */
    getProjectChange() {
      this.getRealData();
      this.judgeData(1)
    },
    chooseDatePicker(val) {
      // 初始化数据
      this.getRealData();
      //校验
      this.judgeData(2)
    },
    // 月份改变事件
    choosePlanDatePicker(val) {
      // 初始化数据
      // this.getPlanData();
    },

    judgeData(type) {
      if (!this.formBaseData.yearMonthStr) {
        return
      }
      if (!this.formBaseData.projectId) {
        return
      }
      // 获取项目投资总额
      let postData = {
        projectId: this.formBaseData.projectId,
        yearMonthStr: this.formBaseData.yearMonthStr,
        companyId: this.formBaseData.companyId
      }
      this.$httpPost('buss/monthInvestProgress/judgeMonthProgress', postData).then(res => {
        if (res.code === 200) {
          if (res.data == 1) {
            this.$message.warning("存在该项目该月投资进度，无法添加")
            if (type === 1) {
              this.formBaseData.projectId = "";
            } else {
              this.formBaseData.yearMonthStr = "";
            }
          }
        } else {
          this.$messageError(res.message)
        }
      }).catch(e => {
        console.log(e);
      })
    },


    // 项目和月份改变时 获取基础数据
    getRealData() {
      if (!this.formBaseData.yearMonthStr) {
        return
      }
      if (!this.formBaseData.projectId) {
        return
      }
      // 获取项目投资总额
      let postData = {
        projectId: this.formBaseData.projectId,
        yearMonthStr: this.formBaseData.yearMonthStr,
        companyId: this.formBaseData.companyId
      }
      this.$httpPost('buss/monthInvestProgress/getBfgData', postData).then(res => {
        if (res.code == 200) {
          this.formBaseData.monthActualFinishValue = res.data.monthActualFinishValue
          this.formBaseData.accumulatedFinish = res.data.accumulatedFinish
          this.formBaseData.monthActualPay = res.data.monthActualPay
          this.formBaseData.accumulatedPayRate = res.data.accumulatedPayRate
          this.formBaseData.finishDescription = res.data.finishDescription
          this.formBaseData.currentDescription = res.data.currentDescription
          this.$forceUpdate()
        } else {
          this.$messageError(res.message)
        }
      }).catch(e => {
        console.log(e);
      })
    },



    uuid() {
      return uuidv4().split('-')[0]
    },
    uploadFile(file, row) {
      //配置一下上传的参数
      row.loading = true
      this.$publicUpload.uploadFile(
        file,
        this.uuid(),
        'monthInvestProgress',
        'file1',
        file.name,
      ).then(res => {
        //成功的回调，往row里面塞fileName
        if (!row.fileList) {
          row.fileList = []
        }
        let arr = JSON.parse(JSON.stringify(row.fileList))
        arr.push({
          name: file.name,
          size: file.size,
          id: res.data[0],
          isLoading: false,
        })
        row.loading = false
        this.$set(row, 'fileList', arr)
        this.$forceUpdate()
        console.log(row.fileList, 'row.fileListrow.fileListrow.fileListrow.fileList')
      }).catch(res => {

      })
    },

    getLocalTime(ns) {
      let date = new Date(ns);
      let year = date.getFullYear()
      let month = date.getMonth() + 1;
      let day = date.getDate()
      month = month < 10 ? '0' + month : month;
      day = day < 10 ? '0' + day : day;
      date = year + '-' + month + '-' + day;
      return date
    },



    /**
     * 月份改变事件
     */
    getMonthChange() {


    },

    /**
     *  根据建设单位查询下面的所有项目
     * */
    getProjectByCompanyId() {
      if (this.formBaseData.companyId) {
        this.companyTree.forEach((item) => {
          if (item.id === this.formBaseData.companyId) {
            this.projectTree = item.children
            if (this.detailType == 'build') {
              this.formBaseData.projectId = this.projectTree[0].id;
              this.getProjectChange();
            }
          }
        })
      }
    },
    // 获取详情请求 api
    getDetail() {
      let id = this.detailId;
      // designStimate.getOne(this.detailId).then(res => {
      this.$httpGet('buss/monthInvestProgress/getOne?id=' + id).then(res => {
        if (res.code == 200) {
          let data = res.data
          this.formBaseData = data
          this.isLock = true
          this.getProjectSectionInfoTree();
          this.$forceUpdate()
          // this.formBaseData = res.data
        } else {
          msgUtil.error2(res.data.message)
        }
      }).catch((res) => {
        msgUtil.error2("获取详情信息失败")
      })

    },
    // 提交详情 提交1/暂存0 新建0/修改1
    submitDetail(type, callback) {
      let submit = 'buss/monthInvestProgress/submit'
      let resubmit = 'buss/monthInvestProgress/resubmit'
      let url = this.detailType == 'build' ? submit : resubmit
      this.formBaseData.isBfg = '2';
      console.log("提交参数。", JSON.stringify(this.formBaseData))
      let params = JSON.parse(JSON.stringify(this.formBaseData))
      let keyArr = ['monthActualFinishValue', 'accumulatedFinish', 'monthActualFinishValueBfg', 'monthActualPay', 'accumulatedPayRate',]
      for (let key in params) {
        if (keyArr.includes(key)) {
          if (params[key] && typeof params[key] === 'string') {
            params[key] = params[key].replace(/[^0-9]/g, '');
          }
        }
      }
      return this.$httpPost(url, params).then(res => {
        if (res.code == 200) {
          // this.formBaseData.id = res.data.data;
          this.detailId = res.data
          this.saveFiles()
          this.$messageSuccess("保存成功")
        } else {
          this.$messageError(res.message);
        }
        if (callback) callback();
      }).catch(e => {
        console.log(e);
        this.$messageError("请求保存数据失败")
      })
    },

    // 点击各个流程的按钮事件
    handleClickDeal(type, res, callback) {
      switch (type) {
        // 取消，关闭窗口
        case 'cancel':
          // 重置表单验证
          if (this.$refs['formBaseData']) {
            this.$refs['formBaseData'].resetFields()
          }
          this.showAudit = false
          this.isShowBpmn = false
          this.qjbywctz = 0;
          this.isLock = false
          this.fileListArr = []
          this.taskKey = ''
          this.formBaseData = {
            id: '',
            companyId: '',
            projectId: '',
            yearMonthStr: '',
            // 本月完成
            realChildren: [],
            // 下月计划
            planChildren: [],
            file: [],
            procInstId: '',
            monthActualFinishValue: '',//月实际完成产值
            accumulatedFinish: '',//累计完成进度
            monthActualFinishValueBfg: '',//月实际完成产值（报发改）
            accumulatedFinishBfg: '',//累计完成进度（报发改）
            monthActualPay: '',//月实际支付
            accumulatedPayRate: '',//累计支付比例
            finishDescription: '',//月完成情况说明
            currentDescription: ''//目前进度说明
          }
          this.variables = {}
          this.flag = false
          //提交按钮清空
          this.showAuditBtn = false
          // 清空文件
          this.leftArr = [
            {
              name: '本年'
            },
            {
              name: '历年'
            }
          ]
          this.selectList.file = []
          this.buildUnitTable = []
          this.selectList = {}
          this.showConsultUnit = true
          this.companyTree = [] // 公司下拉
          this.projectTree = [] // 项目下拉
          this.showBpmnForm = false
          this.detailId = ''
          this.selectList = {
            isConsultUnit: [{
              name: '是',
              value: 1
            }, {
              name: '否',
              value: 0
            }],
            //所有合同
            projectArr: [],
            companyList: [],
            file: []
          }
          // 清空文件
          // 关闭弹窗
          this.formShow = false
          break
        // 保存
        case 'submit':
          let flag = res.flag

          // 验证文件
          /* if (!this.checkoutFile()) {
             this.isLoading = false
             return
           }*/
          // 表单验证
          this.$refs['formBaseData'].validate((valid) => {
            if (valid) {
              // this.isLoading = true
              // 提交详情
              this.submitDetail(flag, () => {

                this.$emit('reloadList')
                this.formShow = false
              }).finally(() => {
                callback && callback();
              })
            } else {
              callback && callback();
            }
          })
          break

      }
    },


    saveFiles() {
      this.$refs['fileOne'].saveAll(this.detailId)
    },


    tableChange(val) {
      this.$set(this, 'buildUnitTable', [...val])
    },


    cancel() {
      this.handleClickDeal('cancel')
    },
    onSave(_, callback) {

      this.handleClickDeal('submit', { flag: 1 }, callback)
    },
    onComplete(data) {
      this.wfNode = data
    },


    fetchData() {
      this.$emit('reloadList')
      this.formShow = false
    },
    download(file) {
      this.$publicUpload.checkFile(file.id, file.name)
    },
    removeFile(file, fileList) {
      fileList.forEach((item, index) => {
        if (file.id === item.id) {
          fileList.splice(index, 1)
        }
      })
      this.$publicUpload.removeFile(file.id)
    },
    newUpNumber() {
      var obj = event.target;
      var t = obj.value.charAt(0);
      obj.value = obj.value.replace(".", "$#$")//把第一个字符'.'替换成'$#$'
        .replace(/\./g, "")//把其余的字符'.'替换为空
        .replace("$#$", ".")//把字符'$#$'替换回原来的'.'
        .replace(/[^\d.]/g, "")//只能输入数字和'.'
        .replace(/^\./g, "")//不能以'.'开头
      // .replace( /([0-9]+\.[0-9]{2})[0-9]*/,"$1")//只保留2位小数
      if (t == '-') {
        obj.value = '-' + obj.value;
      }
      console.log(obj.value);
    },
    newUpNumber_2() {
      var obj = event.target;
      var t = obj.value.charAt(0);
      obj.value = obj.value.replace(".", "$#$")//把第一个字符'.'替换成'$#$'
        .replace(/\./g, "")//把其余的字符'.'替换为空
        .replace("$#$", ".")//把字符'$#$'替换回原来的'.'
        .replace(/[^\d]/g, '')//只能输入数字和'.'
        .replace(/^\./g, "")//不能以'.'开头
      // .replace( /([0-9]+\.[0-9]{2})[0-9]*/,"$1")//只保留2位小数
      if (t == '-') {
        obj.value = '-' + obj.value;
      }
    },

    // 点击锁定上方输入表格，并调用接口获取数据
    lockForm() {
      if (this.formBaseData.yearMonthStr) {
        this.isLock = true
        // this.getRealData();
      } else {
        this.$messageWarning('请选择填报月份')
      }
    }
  }
}
</script>

<style scoped lang="scss">
$borderColor: #c0c4cc;
.contract-ele {
  width: 100%;
}

.contract-ele-long {
  width: 280px;
  width: 98%;
}

.el-input .el-select {
  width: 130px;
}

.formTitle {
  font-weight: bold;
  font-size: 16px;
}

.hoverTxt {
  color: #008fe0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.design-middle-box {
  border: 1px $borderColor solid;
  display: flex;
  flex-direction: row;
  .left-box {
    min-width: 200px;
    padding: 15px;
    border-right: 1px $borderColor solid;
    p {
      cursor: pointer;
    }
  }
  .right-box {
    flex-grow: 1;
    padding: 15px;
  }
  .chooseText {
    color: #008fe0;
  }
}
.actionWidth {
  div:nth-child(1) {
    display: inline-block;
  }
}
.fileText {
  cursor: pointer;
  margin: 0;
  padding-left: 10px;
  display: flex;
  align-items: center;
  img {
    height: 20px;
    margin-right: 15px;
  }
  span {
    width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: keep-all;
    margin-right: 15px;
  }
}
.fileText:hover {
  background-color: rgb(245, 247, 250);
}
.blueText {
  color: #0c8bff;
  margin-left: 15px;
  cursor: pointer;
}
.info-detail-box {
  border: 1px $borderColor solid;
  display: flex;
  flex-direction: row;
  margin: 30px 0;
  .left-box {
    min-width: 300px;
    padding: 0 0 15px 0;
    padding-bottom: 50px;
    border-right: 1px $borderColor solid;
    position: relative;
    .left-content-box {
      padding: 10px;
      max-height: 380px;
      overflow-y: auto;
    }
    p {
      cursor: pointer;
    }
  }
  .right-box {
    flex-grow: 1;
    padding: 15px;
    padding-bottom: 30px;
  }
  .chooseText {
    background-color: #008fe0;
    color: #fff;
  }
}
.left-bottom-group {
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: row;
  justify-content: space-around;
  position: absolute;
  bottom: 10px;
  left: 0;
  .el-button {
  }
  .deleteBatch {
    background-color: rgba(215, 215, 215, 0);
    border-color: #409eff;
    color: #409eff;
  }
}
.flex-row-bridge {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  p {
    margin: 5px 0;
    padding: 0 10px;
    height: 40px;
    line-height: 40px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
  }
  i {
    cursor: pointer;
  }
  i:hover {
    color: #a71c1c;
  }
}
.table {
  width: 100%;
  height: 50px;
  line-height: 50px;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  .td1 {
    width: 90%;
  }
  .td2 {
    width: 8%;
    text-align: center;
  }
}
.table-header {
  background-color: #f2f2f2;
}
.table-grid {
  border: 0.5px solid #eee;
  border-top: none;
}
</style>
<style lang="scss">
.dateRed span {
  border: 1px solid #29b2f5;
  border-radius: 50%;
}
</style>
